package com.maomao.maomaochong_i.personalPackage;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.maomao.maomaochong_i.MainActivity;
import com.maomao.maomaochong_i.R;
import com.maomao.maomaochong_i.application.MyApplication;
import com.maomao.maomaochong_i.dataBean.MySharePreference;

/**
 * Created by maomao on 2017/5/17.
 */

public class PersonalSet extends AppCompatActivity implements View.OnClickListener{
    private Context perContext;
    private Button exitLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.personal_set);
        MyApplication.getInstance().addActivity(this);
        perContext = getApplicationContext();

        Button a1 =(Button)findViewById(R.id.a1);
        Button a2 =(Button)findViewById(R.id.a2);
        Button a3 =(Button)findViewById(R.id.a3);
        exitLogin =(Button)findViewById(R.id.exitLogin);
        exitLogin.setOnClickListener(this);

        a1.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(PersonalSet.this,PensonalMessage.class);
                startActivity(intent);
            }
        });
        a2.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(PersonalSet.this,PersonalPassword.class);
                startActivity(intent);
            }
        });
        a3.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(PersonalSet.this,PersonalAddress.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.exitLogin:
                Toast.makeText(perContext,"已退出登录",Toast.LENGTH_SHORT).show();
                MySharePreference msp = new MySharePreference(perContext);
                msp.removeData("state");
                Intent intent = new Intent(PersonalSet.this, MainActivity.class);
                intent.putExtra("boolean",true);
                startActivity(intent);
                break;
        }
    }
}

